#include "command.h"

//发送文件
void puts_file(int netFD, const char* file_name){

    int fd = open(file_name, O_RDONLY);
    ERROR_CHECK(fd, -1, "open_putsFile.c");
    //获取文件大小
    struct stat file_st;
    fstat(fd, &file_st);
    //发送文件大小
    int ret = send(netFD, &(file_st.st_size), sizeof(file_st.st_size), MSG_NOSIGNAL);
    ERROR_CHECK(ret, -1, "send_putsFile.c");
    //发送文件内容
    ret = sendfile(netFD, fd, 0, file_st.st_size);
    ERROR_CHECK(ret, -1, "sendfile_putsFile.c");

    close(fd);

}
